package com.api.shopapi.service.impl;


import com.api.shopapi.entity.Government;
import com.api.shopapi.entity.dto.GovernmentDTO;
import com.api.shopapi.mapper.GovernmentMapper;
import com.api.shopapi.service.GovernmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("GovernmentServiceImplOne")
public class GovernmentServiceImpl implements GovernmentService {

    @Autowired
    private GovernmentMapper governmentMapper;



    @Override
    public int insert(Government government){
        return governmentMapper.insert(government);
    }

    @Override
    public int deleteByGovernmentCode(String governmentCode){
        return governmentMapper.deleteByGovernmentCode(governmentCode);
    }

    @Override
    public int updateByGovernmentCode(Government government){
        return governmentMapper.updateByGovernmentCode(government);
    }

    @Override
    public Government getByGovernmentCode(String governmentCode){
        return governmentMapper.getByGovernmentCode(governmentCode);
    }

    @Override
    public List<Government> getList() {
        return governmentMapper.getList();
    }



    @Override
    public PageInfo<GovernmentDTO> getPageInfoDTO(int pageIndex, int pageSize){
        PageHelper.startPage(pageIndex, pageSize);
        List<GovernmentDTO> listInstitutionDTO = governmentMapper.getListDTO();
        PageInfo<GovernmentDTO> pageInfo = new PageInfo<GovernmentDTO>(listInstitutionDTO);
        return pageInfo;
    }

    @Override
    public List<Government> getAllGovernmentCode() {
        return governmentMapper.getAllGovernmentCode();
    }

    @Override
    public List<Government> getByCity(String city) {
        return governmentMapper.getByCity(city);
    }

    @Override
    public List<Government> getNormalGovernment() {
        return governmentMapper.getNormalGovernment();
    }


}
